import request from '@/utils/request'

export function verifyToken(): Promise<any> {
    return request({
        method: "get",
        url: "/verifyToken"
    })
}
export function versig(params: { message: string, signature: string }): Promise<any> {
    return request({
        method: "post",
        url: "/versig",
        data: formData(params)
    })
}

export function applyForNode(params: { txhash: string, note: string }): Promise<any> {
    return request({
        method: "post",
        url: "/applyForNode",
        data: formData(params)
    })
}

export function register(params: { address: string }): Promise<any> {
    return request({
        method: "post",
        url: "/register",
        data: formData(params)
    })
}



export function getUserInfo(): Promise<any> {
    return request({
        method: "get",
        url: "/getUserInfo"
    })
}


export function getDirectList(params: { pageNum: number, pageSize: number }): Promise<any> {
    return request({
        method: "get",
        url: "/getDirectList",
        params
    })
}

export function getSTTpriceInfo(params: { pageNum: number, pageSize: number }): Promise<any> {
    return request({
        method: "get",
        url: "/getSTTpriceInfo",
        params
    })
}

export function getSTCpriceInfo(params: { pageNum: number, pageSize: number }): Promise<any> {
    return request({
        method: "get",
        url: "/getSTCpriceInfo",
        params
    })
}

export function swap(params: { pairType: string | number, amount: string }): Promise<any> {
    return request({
        method: "post",
        url: "/swap",
        data: formData(params)
    })
}

export function send(params: { tokenType: string | number, address: string, amount: string }): Promise<any> {
    return request({
        method: "post",
        url: "/send",
        data: formData(params)
    })
}

export function getSendList(params: { pageNum: number, pageSize: number }): Promise<any> {
    return request({
        method: "get",
        url: "/getSendList",
        params
    })
}

export function transfer(params: { tokenType: string | number, address: string, amount: string }): Promise<any> {
    return request({
        method: "post",
        url: "/transfer",
        data: formData(params)
    })
}

export function getTransferList(params: { pageNum: number, pageSize: number }): Promise<any> {
    return request({
        method: "get",
        url: "/getTransferList",
        params
    })
}

export function mintSTC(params: { amount: string | number }): Promise<any> {
    return request({
        method: "post",
        url: "/mintSTC",
        data: formData(params)
    })
}

export function mintSTCBack(params: { id: string | number }): Promise<any> {
    return request({
        method: "post",
        url: "/mintSTCBack",
        data: formData(params)
    })
}



export function getMintSTCList(params: { pageNum: number, pageSize: number }): Promise<any> {
    return request({
        method: "get",
        url: "/getMintSTCList",
        params
    })
}


export function getDayRewardList(params: { pageNum: number, pageSize: number }): Promise<any> {
    return request({
        method: "get",
        url: "/getDayRewardList",
        params
    })
}

export function getNodeRewardList(params: { pageNum: number, pageSize: number }): Promise<any> {
    return request({
        method: "get",
        url: "/getNodeRewardList",
        params
    })
}

export function getParameter(): Promise<any> {
    return request({
        method: "get",
        url: "/getParameter",
    })
}

export function getNodeInfo(): Promise<any> {
    return request({
        method: "get",
        url: "/getNodeInfo",
    })
}

export function isRegisterd(params: { address: string }): Promise<any> {
    return request({
        method: "get",
        url: "/isRegisterd",
        params
    })
}

export function getMinInvest(): Promise<any> {
    return request({
        method: "get",
        url: "/getMinInvest",
    })
}


const formData = (params: any) => {
    let formData = new FormData();
    for (let i in params) {
        formData.append(i, params[i])
    }
    return formData
}